<?php
	class tag{
		function _arclist($attr,$content){
			$row = isset($attr['row'])?$attr['row']:10;
			$titlelen = isset($attr['titlelen'])?$attr['titlelen']:10;
			$wherecatid = isset($attr['catid'])?"hd_news.catid=".$attr['catid']:'';
			$str='';
			$str.='<?php $db = K("newsv");';
			$str.='$rows = $db->join("category")->limit('.$row.')->where("'.$wherecatid.'")->all();';
			$str.='if($rows):';
			$str.='$rows = getarcurl($rows);';
			$str.='foreach($rows as $arc):';
			$str.='$arc["title"]=mb_substr($arc["title"],0,'.$titlelen.',"utf8")?>';
			$str.=$content;
			$str.='<?php endforeach;';
			$str.='endif;?>';
			return $str;
		}
		function _channel($attr,$content){
			$row = isset($attr['row'])?$attr['row']:8;
			$type= isset($attr['type'])?strtolower($attr['type']):"self";
			$cid = isset($attr['cid'])?$attr['cid']:'empty';
			$str = '';
			$str ='<?php $db = M("category");';
			$str.='$db->limit('.$row.');';
			switch($type){
				case 'empty':
				$str.='$rows = $db->all();';
				case 'self':
				$str.='$selfCat = $db->find('.$cid.');';
				$str.='$rows = $db->limit('.$row.')->where("pid =".$selfCat[\'pid\'])->all();';
				break;
				case 'son':
				$str.='$rows = $db->where("pid='.$cid.'")->all()';
				break;
				case 'parent':
				break;
			}
			
			$str.='foreach($rows as $channel):?>';

			$str.=$content;
			$str.='<?php endforeach;?>';
			return $str;

		}
	}


















?>